typedef void (*FUNC_PAINT)(HWND, HDC, PVOID);

int apiRegisterMainWnd(HINSTANCE instancia, char *szClassName, WNDPROC mainWndProc, UINT menuId);
int apiRegisterControlWnd(HINSTANCE instancia, char *className, WNDPROC wndProc);

// Get safe handler to the application data
void *apiRegisterData(HWND hwnd, UINT message, LPARAM lParam);

PVOID apiNew(int len);

void apiFree(PVOID data);

void apiBitmap(HDC pdc, HBITMAP bmp, int x, int y);

void apiOnPaint(HWND hwnd, FUNC_PAINT paintFunction, VOID *data);

// Code shortcuts

#define ON_PAINT(painter) apiOnPaint(hwnd, (FUNC_PAINT)painter, data)

#define GET_DATA(typedata) typedata data = (typedata)apiRegisterData(hwnd, message, lParam)

#define FREE_DATA() apiFree(data)

#define NEW_DATA(typedata) typedata *data = (typedata *)apiNew(sizeof(typedata))

#define NEW_VALUE(typedata, data) typedata *data = (typedata *)apiNew(sizeof(typedata))

#define NEW_VALUE_N(typedata, data, n) typedata *data = (typedata *)apiNew(sizeof(typedata)*n)

#define FREE_VALUE(data) apiFree(data)

#define GET_PRIVATE_DATA(typedata) typedata* data = (typedata*)GetWindowLong(hwnd, GWL_USERDATA)